package cn.wolfcode.shop.service.impl;

import cn.wolfcode.shop.domain.Property;
import cn.wolfcode.shop.mapper.PropertyMapper;
import cn.wolfcode.shop.service.IPropertyService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class PropertyServiceImpl implements IPropertyService {

    @Autowired
    private PropertyMapper propertyMapper;

    @Override
    public List<Property> selectAll() {
        return propertyMapper.selectAll();
    }

    @Override
    public List<Property> queryByCId(Long catalogId) {
        return propertyMapper.selecyByCId(catalogId);
    }

    @Override
    public void saveOrUpdate(Property property) {

        if(property.getId()==null){
            propertyMapper.insert(property);
        }else {
            propertyMapper.updateByPrimaryKey(property);
        }
    }

    @Override
    public void deleteByPId(Long propertyId) {
        propertyMapper.deleteByPrimaryKey(propertyId);
    }
}
